# -*- coding: utf-8 -*-
class JsonResponse(object):
    """
    统一的json返回格式
    """

    def __init__(self, content, status, message):
        self.content = content
        self.status = status
        self.message = message

    @classmethod
    def success(cls, data=None, code=200, msg='success'):
        return cls(data, code, msg)

    @classmethod
    def error(cls, data=None, code=500, msg='error'):
        return cls(data, code, msg)

    def to_dict(self):
        return {
            "status": self.status,
            "message": self.message,
            "content": self.content
        }
